<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <script>

    // 普通函数和箭头函数的this指向
    // 普通函数: 谁调用this指向谁, 就看谁在.它
    // 箭头函数: 箭头函数本身没有this, this会自动绑定到调用时所处的环境
    const zs = {
      name: 'zs',
      sayHello: function sayHello() {
        console.log('sayHello :this  ----->  ', this);  // this指向谁?
      },
      sayHi: () => {
        console.log('sayHi: this  ----->  ', this);  // this指向谁?
      }
    };

    zs.sayHello();  // zs
    zs.sayHi(); // window

  </script>

</body>

</html>